package farmaciaweb.com.br.entity;

import java.io.Serializable;
import java.lang.String;
import javax.persistence.*;
import static javax.persistence.GenerationType.SEQUENCE;

@Entity
@NamedQueries(value = {
		@NamedQuery(name = "bd_farmaciaweb.consultaTransportadora", query = "SELECT t FROM Transportadora t " +
																"where (t.nmTransportadora like :nome) " + 
																" and ((t.cnpj = :cnpj) OR ('' = :cnpj))")})

public class Transportadora implements Serializable{

	private static final long serialVersionUID = 1922097820165275405L;

	@Id
	@Column(name = "idTransportadora")
	@GeneratedValue(strategy = SEQUENCE, generator = "transp_gen")
	@SequenceGenerator(name = "transp_gen", sequenceName = "transp_seq", allocationSize = 5)
	private int idTransportadora;
	
	public Transportadora() {
		super();
	}
	
	@Column(nullable = false, length = 40)
	private String nmTransportadora;
	
	@Column(nullable = false, length = 14, unique = true)
	private String cnpj;
	
	@Column(nullable = false, length = 120)
	private String enderecoTransp;
	   
	public int getIdTransportadora() {
		return this.idTransportadora;
	}

	public void setIdTransportadora(int idTransportadora) {
		this.idTransportadora = idTransportadora;
	}   
	public String getNmTransportadora() {
		return this.nmTransportadora;
	}

	public void setNmTransportadora(String nmTransportadora) {
		this.nmTransportadora = nmTransportadora;
	}   
	
	public String getEnderecoTransp() {
		return this.enderecoTransp;
	}

	public void setEnderecoTransp(String enderecoTransp) {
		this.enderecoTransp = enderecoTransp;
	}
	
	public String getCnpj() {
		return cnpj;
	}

	public void setCnpj(String cnpj) {
		this.cnpj = cnpj;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((cnpj == null) ? 0 : cnpj.hashCode());
		result = prime * result + idTransportadora;
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Transportadora other = (Transportadora) obj;
		if (cnpj == null) {
			if (other.cnpj != null)
				return false;
		} else if (!cnpj.equals(other.cnpj))
			return false;
		if (idTransportadora != other.idTransportadora)
			return false;
		return true;
	}	
}